//package com.ruoyi.user.controller;
//
//import com.ruoyi.common.core.web.domain.AjaxResult;
//import com.ruoyi.user.service.SsmService;
//import com.ruoyi.user.sms.Email;
//import com.ruoyi.user.sms.ShortMessageParams;
//import com.ruoyi.user.utils.Servlets;
//import io.swagger.v3.oas.annotations.Operation;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//
//
///**
// * 短信验证码 Controller
// *
// * @author PONY
// */
//@Tag(name = "短信接口")
//@RestController
//@RequestMapping("user/sms")
//public class SmsController {
//    @Autowired
//    private SsmService ssmService;
//
//    @Operation(summary = "发送手机短信")
//    @PostMapping("/mobile")
//    public AjaxResult mobileMessage(@RequestBody ShortMessageParams params, HttpServletRequest request) {
//        // 验证码是否正确
////        if (!captchaTokenService.validateCaptcha(params.captchaToken, params.captcha)) {
////            return Responses.failure(request, "error.captchaIncorrect");
////        }
//        // IP发送短信是否超过限制次数
////        if (ipSmsCounterService.isExcessive(ip, sms.getMaxPerIp())) {
////            return Responses.failure(request, "error.ipSendSmsExcessive");
////        }
//        String messageId = ssmService.sendMobileMessage(params.receiver);
//        if (StringUtils.isNotEmpty(messageId)) {
//            return AjaxResult.success(messageId);
//        }
//        return AjaxResult.error("发送手机号验证码失败");
//    }
//
//    @Operation(summary = "发送邮件短信")
//    @PostMapping("/email")
//    public AjaxResult emailMessage(@RequestBody ShortMessageParams params, HttpServletRequest request) {
//        // 验证码是否正确
////        if (!captchaTokenService.validateCaptcha(params.captchaToken, params.captcha)) {
////            return Responses.failure(request, "error.captchaIncorrect");
////        }
//        String ip = Servlets.getRemoteAddr(request, 1);
//        Email emailConfig = new Email();
//        // IP发送短信是否超过限制次数
////        if (ipSmsCounterService.isExcessive(ip, emailConfig.getMaxPerIp())) {
////            return Responses.failure(request, "error.ipSendSmsExcessive");
////        }
//        // 短信功能未开启
//        if (StringUtils.isBlank(emailConfig.getHost())) {
//            return AjaxResult.error("error.emailNotEnabled");
//        }
//        String messageId = ssmService.sendMail(new String[]{params.receiver});
//        if (StringUtils.isNotEmpty(messageId)) {
//            return AjaxResult.success(messageId);
//        }
//        return AjaxResult.error("发送手机号验证码失败");
//    }
//
//
//}
